<template>
	<Layout class="p-5 bg-white">
		<Form :model="cutDepositRecord" :label-width="130">
			<Col span="8">
			<FormItem class="w-100" label="扣押记录编号">
				<label>: {{this.param.cutId}}</label>
			</FormItem>
			<FormItem class="w-100" label="客户名称">
				<label>: {{this.clientName}}</label>
			</FormItem>
			<FormItem class="w-100" label="创建时间">
				<label>: {{this.ct}}</label>
			</FormItem>
			<FormItem class="w-100" label="金额">
				<label>: {{this.amount}}</label>
			</FormItem>
			<FormItem class="w-100" label="门店">
				<label>: {{this.name}}</label>
			</FormItem>
			<FormItem class="w-100" label="扣押状态">
				<label v-if="param.ioFlg === false">扣押金</label>
				<label v-else-if="param.ioFlg === true">取消扣押</label>
			</FormItem>
			<FormItem class="w-100" label="原因">
				<Input v-model="param.reason" type="textarea" :rows="4" placeholder="原因" />
			</FormItem>
			<FormItem>
				<Button v-if="param.ioFlg === false" class="m-2" type="primary" @click="changeCut">取消扣押</Button>
				<Button class="m-2" style="margin-left: 16px" @click="cancel()">关闭</Button>
			</FormItem>
			</Col>


		</Form>
	</Layout>
</template>
<script>
	export default {
		data() {
			return {
				param: {
					cutId: "",
					ioFlg: "",
					ct: "",
					amount: "",
					reason: ""
				},
				clientName: "",
				ct: "",
				amount: "",
				name: "",
			}
		},
		methods: {
			getCut: function() {
				this.http.get({
					url: "/client/deposit-record/"+this.param.cutId+"/cut",
				}).then(data => {
					this.param.cutId = data.cut_deposit_record.cutId;
					this.clientName = data.client.clientName;
					this.ct = data.cut_deposit_record.ct;
					this.amount = data.cut_deposit_record.amount / 100;
					this.name = data.store.name;
					this.param.ioFlg = data.cut_deposit_record.ioFlg;
					this.param.reason = data.cut_deposit_record.reason;
				});
			},
			changeCut: function() {
				this.http.put({
					url: "/client/deposit-record/"+this.param.cutId+"/cut/cancel",
				}).then(() => {
					this.message.info("取消扣押成功，押金已退还到客户账户上。");
					this.$tabs.close();
				});
			},
			cancel: function() {
				this.$tabs.close();
			}
		},
		created() {
			this.param.cutId = this.$route.query.cutId;
			this.getCut();
		}
	}
</script>

<style>
</style>
